package org.example.lotterysystem.dao.mapper;

import org.apache.ibatis.annotations.*;
import org.example.lotterysystem.dao.dataobject.ActivityDO;

import java.util.List;

@Mapper
public interface ActivityMapper {
    @Insert("insert into activity(activity_name,description,status) " +
            "values (#{activityNmae},#{description},#{status})")
    @Options(useGeneratedKeys = true,keyProperty = "id",keyColumn = "id")
    int insert(ActivityDO activityDO);

    @Select("select count(1) from activity")
    int count();

    @Select("select * from prize order by desc limit #{offset},#{pageSize}")
    List<ActivityDO> selectActivityList(@Param("offset") Integer offset,@Param("pageSize") Integer pageSize);

    @Select("select * from activity where id=#{activityId}")
    ActivityDO selectById(@Param("activityId") Long activityId);

    @Update("update activity set status =#{status} where id=#{activityId}")
    void updateStatus(Long activityId, String status);
}
